import http from '@/utils/http'

const BASE_URL = '/education/arrange'

export interface ArrangeTemplate {
  id: string
  name: string
  fullName: string
  classYear: number
  term: string
  grade: string
  lessonCount: number
  startDate: string
  endDate: string
}

export interface ArrangeTemplateQuery {
  keyword?: string
  term?: string | number
  grade?: string | number
  classYear?: string | number
  endDate?: string | number
  startDate?: string | number
}

export interface ArrangeTemplateResp extends ArrangeTemplate {

}

export interface LessonQuery {
  lessonIndex: number
  lessonDate: string
}

export interface ArrangeTemplateReq {
  name: string
  fullName?: string
  classYear?: string | number
  term?: string | number
  grade?: string | number
  lessonCount?: number
  startDate?: string | number
  endDate?: string | number
  lessonList?: Array<LessonQuery>
}

export const getArrangeTemplatePage = (query: ArrangeTemplateQuery & PageQuery) => {
  return http.get<Page<ArrangeTemplateResp[]>>(`${BASE_URL}/template/page`, query)
}

export const getArrangeTemplateList = (query: ArrangeTemplateQuery) => {
  return http.get<ArrangeTemplateResp[]>(`${BASE_URL}/template/list`, query)
}

export const createArrangeTemplate = (data: ArrangeTemplateReq) => {
  return http.post(`${BASE_URL}/template/create`, data)
}

export const getArrangeTemplateDetail = (id: string) => {
  return http.get(`${BASE_URL}/template/detail/${id}`)
}

export const updateArrangeTemplate = (data: ArrangeTemplateReq, id: string | number) => {
  return http.post(`${BASE_URL}/template/update/${id}`, data)
}

export const deleteArrangeTemplate = (id: string | number) => {
  return http.post(`${BASE_URL}/template/delete/${id}`)
}
